#ifndef CHANNEL_H
#define CHANNEL_H

#include <functional>

enum class FDEvent {
    TimeOut = 0x01,
    ReadEvent = 0x02,
    WriteEvent = 0x04
};

class Channel
{
public:
    using handleFunc = std::function<int(void*)>;

    Channel(int fd, FDEvent events, handleFunc readFunc,
            handleFunc writeFunc, handleFunc destroyFunc,void* arg);
    handleFunc readCallback;
    handleFunc writeCallback;
    handleFunc destroyCallback;

    void writeEventEnable(bool flag);

    bool isWriteEventEnable();

    inline int getEvent() {
        return m_events;
    }
    inline int getSocket(){
        return m_fd;
    }
    inline const void* getArg() {
        return m_arg;
    }

private:
    int m_fd;
    int m_events;
    void* m_arg;
};

#endif // CHANNEL_H
